<script lang="ts">
import { defineComponent, defineAsyncComponent, onMounted, reactive, ref } from "vue";
import router from "@/router";
import {
  getAdvImages,
  getArticleList,
  getCompanyList,
  getCompanyJoinCategoryList,
} from "@/network/api";
import {} from "@/network/Productapi";
import resizeRank from "@/util/screen";

const banner = defineAsyncComponent(() => import("@/components/banner.vue"));
const ContactComp = defineAsyncComponent(() => import("@/components/contact.vue"));
const productComp = defineAsyncComponent(() => import("@/components/product.vue"));
const empowermentComp = defineAsyncComponent(
  () => import("./components/empowerment.vue")
);
// const newsComp = defineAsyncComponent(() => import('@/components/news.vue'))
const serviceComp = defineAsyncComponent(() => import("./components/service.vue"));
const caseComp = defineAsyncComponent(() => import("./components/customCase.vue"));
const interflowComp = defineAsyncComponent(() => import("@/components/interflow.vue"));
import newsComp from "@/components/news.vue";

export default defineComponent({
  name: "swiper-example-loop",
  title: "Loop mode / Infinite loop",
  url: import.meta.url,
  components: {
    banner,
    ContactComp,
    empowermentComp,
    newsComp,
    productComp,
    serviceComp,
    caseComp,
    interflowComp,
  },
  async setup() {
    const bannerList = ref([]) as any;
    const trendList = ref([]) as any;
    const caseList = ref([]) as any;
    const solutionList = ref([]) as any;
    const empowermentList = ref([]) as any;
    const bannerShow = ref("false");
    const rank = ref(0);
    let data = reactive({
      swiperType: false,
      videoTtpeImg: true,
      value: "",
      options: [
        {
          value: "Option1",
          label: "Option1",
        },
      ] as any,
      page:1,
      companyList: [] as any,
      count: 0,
    });
    onMounted(() => {
      /**
       * @methods 判定pc&movie
       */
      rank.value = resizeRank(rank.value);
      window.addEventListener("resize", () => {
        let screenWidth = document.body.clientWidth;
        if (screenWidth < 768) {
          rank.value = 1;
        } else {
          rank.value = 0;
        }
      });
    });

    /**
      @methods 获取公司列表
    */
    const change = async () => {
      const { data: companyList } = await getCompanyList({ cid: data.value,page: data.page, pageSize: 8 });
      data.companyList = companyList.list;
      data.count = companyList.count;
    };
    change()
    /**
      @methods 获取公司列表
    */
    const { data: CompanyJoinCategoryList } = await getCompanyJoinCategoryList();
    data.options = CompanyJoinCategoryList;

    /**
      @methods 获取banner
    */
    const { data: bannerData } = await getAdvImages({ type: "index" });
    bannerList.value = bannerData;

    /**
      @methods 获取动态
    */
    const { data: trendData } = await getArticleList({
      article_category_alias: "trends",
      page: 1,
      pageSize: 10,
    });
    trendData.list.forEach((item: any) => {
      item.check = false;
    });
    trendList.value = trendData.list;
    // /**
    //    @methods 获取案例
    //  */
    // const { data: caseData } = await getArticleList({
    //   article_category_alias: "case",
    //   page: 1,
    //   pageSize: 10,
    // });
    // caseData.list.forEach((item: any) => {
    //   item.check = false;
    // });
    // caseList.value = caseData.list;
    /**
      @methods 获取方案
    */

    const onPlayVideo = () => {
      bannerShow.value = "none";
    };

    const PageChange = (page: any) => {
      console.log(page,"PageChange");
      data.page = page;
    change()

    }
    const touchMove = () => {
      data.swiperType = true;
    };
    const handleGoNews = (val: string) => {
      router.push({
        path: "/News",
        query: {
          alias: val,
        },
      });
    };
    const introduce = () => {
      router.push({
        path: "/about",
      });
    };
    const toParnterWeb = (item: any) => {
      // if (item.link) {
      //     window.open(item.link)
      // }
    };
    const handleGoSolution = (val: any) => {
      router.push({
        path: "/Solutions",
        query: {
          id: val.id,
          name: val.name,
          t: Date.now(),
        },
      });
    };
    const handleCompany = (val: string) => {
      router.push({
        path: "/companyData",
        query: {
          id: val,
        },
      });
    };

    return {
      rank,
      data,
      bannerList,
      trendList,
      caseList,
      empowermentList,
      touchMove,
      onPlayVideo,
      bannerShow,
      handleGoNews,
      handleGoSolution,
      handleCompany,
      change,
      introduce,
      PageChange
    };
  },
});
</script>

<template>
  <banner :list="bannerList" :isShowBtn="1"></banner>

  <div class="pcshow">
    <div class="content">
      <div class="highlightTitle bigTitle">基地介绍</div>
      <div class="highlightContent">
        <div class="highlightLeft">
          <el-row :gutter="94">
            <el-col :span="13" :xs="24">
              <div class="highlightLeftText">
                <div class="LeftTextDemand contentText">
                  惠州仲恺高新区是1992年经国务院批准成立的国家级高新区。地处深莞惠“黄金三角”中心，区位优势明显，代表惠州先后获得国家电子信息产业基地、国家火炬计划数码试听产业基地、国家火炬计划激光头特色产业基地、国家通信高新技术产业化基地、国家知识产权试点园区、国家博士后科研工作站、国家科技企业孵化器和国家新型工业化产业示范基地等多个国字号招牌。
                </div>
                <div class="LeftTextDemand contentText">
                  2020年仲恺高新区获得”国家级外贸转型升级基地（电子信息）”称号，委托“惠州市电子信息产业协会”建立基地专职工作站，积极宣传和推广仲恺电子产品和企业，助力区内外贸企业开拓国内外市场，推动仲恺高新区外贸转型升级和高质量发展，也为惠州市打造万亿级电子信息产业集群贡献力量。
                </div>
              </div>
            </el-col>
            <el-col :span="11" :xs="24">
              <div class="highlightLeftImg scaleImgCard">
                <img src="https://huizhoueii.obs.cn-east-3.myhuaweicloud.com/homeImg1.jpg" alt="" />
              </div>
            </el-col>
          </el-row>
        </div>
      </div>
      <el-button color="#085dde" class="btn1" @click='introduce'>了解详情 ></el-button>
    </div>
  </div>

  <div class="content text_center">
    <div class="bigTitle">优秀企业</div>
    <div class="contentText" style="margin: 33px 0">
      开拓创新，促进高质量发展
    </div>
    <div>
      <el-select
      clearable
        @change="change"
        v-model="data.value"
        class="m-2"
        placeholder="全部"
        size="large"
      >
        <el-option
          v-for="item in data.options"
          :key="item.name"
          :label="item.name"
          :value="item.id"
        />
      </el-select>
    </div>
    <div class="module2Content">
      <div class="flex flex_wrap  width100">
        <div
          class="cooperate parnterLogo"
          v-for="item in data.companyList"
          :key="item"
          @click="handleCompany(item.id)"
        >
          <div class="imgBox">
            <img v-if="item.logo" :src="item.logo" alt="" class="parnterLogoImg" />
            <div v-else style="height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    background-color: #fff;">{{ item.alias }}</div>
          </div>
          <div class="contentText">{{ item.name }}</div>
        </div>

        <div class='flex justify_end width100'>
          <el-pagination
            layout="total, prev, pager, next, jumper"
            :page-size="8"
            :total="data.count"
            @current-change="PageChange"
          />
        </div>
      </div>
    </div>
  </div>

  <div class="ove_h bgfff">
    <div class="content">
      <div style="display: flex; justify-content: space-between">
        <div class="content-title bigTitle">最新动态</div>
        <el-button @click="handleGoNews('trends')" color="#085dde" class="btn1"
          >了解更多</el-button
        >
      </div>
      <div>
        <newsComp
          :style="{
            'margin-left': data.swiperType ? '0px' : '0px',
            transition: '3s margin-lef',
          }"
          @touchMove="touchMove"
          :newsList="trendList"
          :rank="rank"
        ></newsComp>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
@import url("@/assets/css/content.css");

::v-deep .el-input--large {
  width: 100% !important;
}

.cooperate {
  width: 297px;
  margin-bottom: 40px;
  img {
    object-fit: cover;
    border-radius: 10px;
    width: 100%;
    height: 100%;
  }
}

.module2Content {
  padding: 40px 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;

  .parnterLogo {
    // width: 18%;
    margin: 0 24px 30px 24px;
    //小手
    cursor: pointer;
    .imgBox {
      // width: 297px;
      overflow: hidden;
      height: 168px;
      border-radius: 20px;
      margin-bottom: 20px;
    }
    img {
      width: 100%;
      overflow: hidden;
      transition: all 0.5s;
    }

    .contentText {
    }
    img:hover {
      transform: scale(1.2);
    }
  }
}
.btn1 {
  font-size: 18px;
  color: #fff;
  height: 43px;
  width: 130px;
}

.pcshow {
  background-color: #fff;
}
.content {
  margin: 0 auto;
  padding: 0 30px;

  .highlightTitle {
    padding: 30px 0 0 0;
    text-align: left;
    padding-left: 0px;
  }

  .highlightContent {
    padding: 40px 0 60px 0;

    .highlightLeft {
      display: flex;
      overflow: hidden;

      .highlightLeftText {
        text-indent: 2em;
        overflow: hidden;
        /* 三行显示省略号 */
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 11;
        .LeftTextTitle {
          padding: 40px 0;
        }
        .LeftTextDemand {
          margin-bottom: 20px;
        }
      }

      .highlightLeftImg {
        // width: 50%;
        // height: 360px;
        border-radius: 20px;

        img {
          width: 100%;
          height: 100%;
          object-fit: cover;
          border-radius: 20px;
        }
      }
    }

    .highlightRight {
      display: flex;

      .highlightRightImg {
        width: 50%;
        height: 100%;
        border-radius: 20px;

        img {
          width: 100%;
          height: 100%;
          object-fit: cover;
          border-radius: 20px;
        }
      }

      .highlightRightText {
        width: 50%;
        padding: 0 0 0 80px;

        .RightTextTitle {
          padding: 40px 0;
          font-weight: 500;
        }
      }
    }
  }
}

.All {
  border: 0px;
  color: $mainColor !important;
  background: #f5f5f7ff;
}

.All:hover {
  background-color: #fff;
}

.NewAll {
  border: 0px;
  color: $mainColor !important;
}

.NewAll:hover {
  background-color: #f5f5f7ff;
}

.el-carousel {
  width: 100%;
}

.el-carousel__item img {
  width: 100%;
  height: 100%;
}

.content {
  margin: 0 auto;
  padding-top: 70px;
  padding-bottom: 70px;

  .content-title {
    display: flex;
    align-items: center;
  }

  .jdt {
    margin-top: 60px;
    border-radius: 15px;

    img {
      padding: 10px;
      width: 100%;
      height: 100%;
      object-fit: contain;
    }

    .jdt-ctn {
      word-wrap: break-word;
      word-break: normal;
      padding: 20% 10% 20% 0;
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
    }
  }
}

.el-tabs__nav-wrap::after {
  width: 0 !important;
}

@media screen and (max-width: 450px) {
  .secondaryContent {
    text-align: center;
  }
  .parnterLogo {
    width: 100% !important;
    margin-bottom: 20px;
  }
}

@media screen and (max-width: 768px) {
  .jdt-ctn {
    text-align: center;
    padding: 10% !important;

    .bigTitle {
      margin-bottom: 8px;
    }

    .contentText {
      margin-bottom: 8px;
    }
  }

  .bannerContent {
    .bannerContentPart {
      height: 166%;
    }

    .bannerText {
      left: 0;
    }
  }
}
</style>
